package myProject.gwt.client.simpleTable;

import com.google.gwt.event.dom.client.MouseDownEvent;
import com.google.gwt.event.dom.client.MouseDownHandler;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.FocusPanel;
import com.google.gwt.user.client.ui.Widget;

public class Sizer extends Composite implements ISizer{
	
	private FocusPanel fp = new FocusPanel();
	private int columnIndex;
	private ISizerListener listener;
	
	public Sizer(int columnIndex) {
		super();
		initWidget(fp);
		fp.setPixelSize(5, 20);
		fp.setStylePrimaryName("sizer");
		this.columnIndex = columnIndex;
		
		fp.addMouseDownHandler(new MouseDownHandler(){

			@Override
			public void onMouseDown(MouseDownEvent event) {
				if(listener != null) listener.MouseDown();				
			}
			
		});
	}

	@Override
	public int getColumnIndex() {
		return columnIndex;
	}

	@Override
	public Widget getComponent() {
		return this;
	}

	@Override
	public void setListener(ISizerListener listener) {
		this.listener = listener;
	}

	
	
}
